// 登录
const login = function (userInfo) {
    request.request({
        url: 'community/user/login',
        method: 'post',
        data: {
            userInfo: userInfo
        }
    }).then(res => {
        layer.msg(res.msg)
        if (res.code === 200) {
            // 登录成功
            Cookies.set('is_login', true);
            window.location.href = `${window.location.origin}/cms/home/cms-pages`
        }
    })
}

// 用户注册
const userRegister = function (params) {
    return request.request({
        url: 'community/user/register',
        method: 'post',
        data: {
            registerForm: params
        }
    })
}

// 发送邮件/短信
const sendSms = function (params) {
    return request.request({
        url: 'community/tool/sms',
        method: 'post',
        data: params
    })
}

// 获取微信授权地址
const getWeChatCommunityAuthUrl = function (params) {
    return request.request({
        url: '../home/api/authorized/wechat_community',
        method: 'get',
        params: params
    })
}

// 获取用户信息
const getUserInfo = function () {
    return request.request({
        url: 'community/user/get_user_info',
        method: 'get'
    })
}

const upUserInfo = function (parameter) {
    return request({
        url: 'community/user/update_user_info',
        method: 'post',
        data: parameter
    })
}